#ifdef GL_FRAGMENT_PRECISION_HIGH
   // Default precision
   precision highp float;
#else
   precision mediump float;
#endif

#ifdef GL_FRAGMENT_PRECISION_HIGH
   // Default precision
   precision highp float;
#else
   precision mediump float;
#endif

uniform sampler2D outline;
uniform vec4 material;

varying vec3  vNormal;
varying vec3  vLight1;
varying vec3  vLight2;
varying vec3  vLight3;
varying vec3  vView;

void main(void)
{
  
   vec3 norm = normalize (vNormal);
  
   vec2 texCoord = vec2(1.0 - dot (norm, normalize(vView)), 0.5);
   vec3 outline = texture2D(outline, texCoord).xyz;

   float lighting = (dot (normalize (vLight1), norm) * 0.5 + 0.5) +
                    (dot (normalize (vLight2), norm) * 0.5 + 0.5) +
                    (dot (normalize (vLight3), norm) * 0.5 + 0.5);
   //lighting = max(0.0, lighting);                    

   gl_FragColor = vec4(outline,1.0) * vec4(lighting) * material; 
}   
